package cn.kgc.springbootdemo.vo;


import cn.hutool.core.bean.BeanUtil;
import cn.kgc.springbootdemo.common.Convert;
import cn.kgc.springbootdemo.entity.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDate;

/**
 * <h3>springbootdemo</h3>
 * <p>用户VO</p>
 *
 * @author : DongZeJian
 * @date : 2020-04-29 14:33
 **/
@Data
@ApiModel("用户VO")
@NoArgsConstructor
@AllArgsConstructor
public class UserVO implements Serializable, Convert<UserVO, User> {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @ApiModelProperty(value = "主键",name = "id")
    private String id;


    /**
     * 用户名称
     */
    @ApiModelProperty(value = "用户名称",name ="userName")
    private String userName;

    /**
     * 性别
     */
    @ApiModelProperty(value = "性别",name = "sex")
    private String sex;

    /**
     * 角色
     */
    @ApiModelProperty(value = "角色",name = "role")
    private String role;

    /**
     * 电话号码
     */
    @ApiModelProperty(value = "电话号码",name = "phone")
    private String phone;

    @ApiModelProperty(value = "身份证")
    private String idCard;

    /**
     * 出生日期
     */
    @ApiModelProperty(value = "出生日期",name = "birth")
    private LocalDate birth;


    @Override
    public User doforward() {
        User user=new User();
        BeanUtil.copyProperties(this,user);
        return user;
    }

    @Override
    public  UserVO doBackward(User user) {
        UserVO userVO=new UserVO();
        BeanUtil.copyProperties(user,this);
        return userVO;
    }
}
